package cn.vcjf.weapp.api.setting.entity;

import cn.vcjf.weapp.api.setting.service.OrderOptionService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @Auther: zhengzihang
 * @Date: 2018/10/15 10:48
 * @Description:
 */
@Component
public class OrderOptionConfig {
	/**
	 *砍价限制分钟
	 */
	public Integer cut_active_expire_time;
	/**
	 * 拼团限制分钟
	 */
	public Integer team_active_expire_time;
	/**
	 *  订单完成不能申请售后的超时天数
	 */
	public Integer expireDays;
	/**正常订单超时关闭分钟*/
	public Integer genAutoFailedTime;
	/** 拼团订单超时关闭分钟*/
	public Integer teamAutoFailedTime;
	/** 砍价订单超时关闭分钟*/
	public Integer cutAutoFailedTime;
	/** 发货超时自动完成天数*/
	public Integer autoCompletDate;
	/**
	 * 分润,一级分润比例
	 */
	public Integer profit_scale;
	/**
	 * 分润,二级分润比例
	 */
	public Integer profit_indirect_scale;
	/**
	 * 未评论订单的自动评论超时天数
	 */
	public Integer NotCommentOrderExpireDays;

	@Resource
	private OrderOptionService orderOptionService;

	@PostConstruct
	public void init(){
		orderOptionService.getOrderOptions(this);
		checkProperties();
	}

	private void checkProperties() {
		if(expireDays == null){
			expireDays = 7;
		}
		if(genAutoFailedTime == null){
			genAutoFailedTime = 60*60*24;
		}
		if(teamAutoFailedTime == null){
			teamAutoFailedTime = 60*60*24;
		}
		if(cutAutoFailedTime == null){
			cutAutoFailedTime = 60*60*24;
		}
		if(autoCompletDate == null){
			cutAutoFailedTime = 60*60*24*7;
		}
		if(profit_scale == null){
			profit_scale = 0;
		}
		if(profit_indirect_scale == null){
			profit_indirect_scale = 0;
		}
		if(NotCommentOrderExpireDays == null){
			NotCommentOrderExpireDays = 7;
		}
		if(cut_active_expire_time == null){
			cut_active_expire_time = 60*60*24;
		}
		if(team_active_expire_time == null){
			team_active_expire_time = 60*60*24;
		}
	}

}
